<template>
	<view class="container">
			<uni-list>
				<uni-list-item v-for="item,index in list" :key="index" 
					:title="item.name" :thumb="'/static'+item.icon"
					clickable="true" :to='"../fooddetail/fooddetail?id="+item.id'
					thumbSize="lg" :rightText="'￥'+item.price+'元'" 
					:clickable="true" :showArrow="true"></uni-list-item>
			</uni-list>
		</view>
</template>

<script>
	export default {
		data() {
			return {
						"list": []
                     }
				},
				methods:{
					loadfood(){
								uni.request({
									url: 'http://localhost:8090/foodapp/food/list',
									method: 'POST',
									data: {},
									success: res => {
										if (res.data.success) {
											this.list = res.data.data
											uni.showToast({title: '成功',icon: 'none'});
											
										} else {
											this.list = []
											uni.showToast({	title: '失败',icon: 'none'});
										}
									},
									fail: () => {uni.showToast({title: '失败',icon: 'none'});},
									complete: () => {
										
									}
								});
							}
						},
						
						onShow() {
							console.log("onShow");
						},
						onHide() {
							console.log('onHide');
						},
						onUnload() {
							console.log('onUnload');
						},
						onPullDownRefresh() {
							this.loadfood()
							uni.stopPullDownRefresh();
						},
						onLoad()  {
							this.loadfood()
						}
					}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
